package gervosou;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.DropMode;
import java.awt.Color;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.GregorianCalendar;
import javax.swing.JSeparator;

public class VueNouvSociete extends Vue {

	/**
	 * 
	 */
	//private static final long serialVersionUID = 5069349224425178639L;
	private JPanel contentPane;
	private JTextField textFieldNom;
	private JTextField textFieldAdresse;
	
	// pour que les boutons soient des attributs, il faut faire "convert local to field"
	private JButton btnEnregistrer;
	private JButton btnAnnuler;

	// a ajouter car la vue est observatrice d'un client
		private ClientPhysique _client ;
		private JTextField textFieldPrenomPDG;
		private JTextField textFieldNomPDG;
		private JTextField textFieldMailContact;
		private JLabel lblMailDeContact;
	
	/**
	 * Create the frame.
	 */
	public VueNouvSociete(Controleur controleur) {
		super (controleur);
		setTitle("Enregistrement d'une nouvelle societe");
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 485, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNom = new JLabel("Nom Societe");
		lblNom.setBounds(27, 37, 87, 16);
		contentPane.add(lblNom);
		
		textFieldNom = new JTextField();
		textFieldNom.setBounds(122, 32, 190, 28);
		textFieldNom.setBackground(new Color(255, 255, 255));
		contentPane.add(textFieldNom);
		textFieldNom.setColumns(10);
		
		btnEnregistrer = new JButton("Enregistrer");
		btnEnregistrer.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String nomSoc = textFieldNom.getText();
				String prenomPDG = textFieldPrenomPDG.getText();
				String adresse = textFieldAdresse.getText();
				String nomPDG = textFieldNomPDG.getText();
				String mailContact = textFieldMailContact.getText();
				getControleur().nouvSociete(nomSoc,nomPDG , prenomPDG, adresse, mailContact);}
		});
		btnEnregistrer.setBounds(348, 19, 117, 52);
		contentPane.add(btnEnregistrer);
		
		btnAnnuler = new JButton("Annuler");
		btnAnnuler.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getControleur().fermerVue(VueNouvSociete.this);
			}
		});
		btnAnnuler.setBounds(348, 83, 117, 29);
		contentPane.add(btnAnnuler);
		
		JLabel lblAdresse = new JLabel("Adresse");
		lblAdresse.setBounds(53, 77, 61, 16);
		contentPane.add(lblAdresse);
		
		textFieldAdresse = new JTextField();
		textFieldAdresse.setColumns(10);
		textFieldAdresse.setBounds(122, 72, 190, 28);
		contentPane.add(textFieldAdresse);
		
		JSeparator separator = new JSeparator();
		separator.setBounds(4, 158, 298, 2);
		contentPane.add(separator);
		
		JLabel lblInfosSurPdg = new JLabel("Infos sur PDG:");
		lblInfosSurPdg.setBounds(7, 172, 97, 15);
		contentPane.add(lblInfosSurPdg);
		
		JLabel lblInfosDeBase = new JLabel("Infos de base:");
		lblInfosDeBase.setBounds(7, 12, 97, 15);
		contentPane.add(lblInfosDeBase);
		
		textFieldPrenomPDG = new JTextField();
		textFieldPrenomPDG.setColumns(10);
		textFieldPrenomPDG.setBounds(122, 234, 190, 28);
		contentPane.add(textFieldPrenomPDG);
		
		JLabel lblPrenomPdg = new JLabel("Prenom PDG");
		lblPrenomPdg.setBounds(27, 240, 87, 15);
		contentPane.add(lblPrenomPdg);
		
		JLabel lblNomPdg = new JLabel("Nom PDG");
		lblNomPdg.setBounds(43, 199, 61, 16);
		contentPane.add(lblNomPdg);
		
		textFieldNomPDG = new JTextField();
		textFieldNomPDG.setColumns(10);
		textFieldNomPDG.setBounds(122, 194, 190, 28);
		contentPane.add(textFieldNomPDG);
		
		textFieldMailContact = new JTextField();
		textFieldMailContact.setColumns(10);
		textFieldMailContact.setBounds(122, 112, 190, 28);
		contentPane.add(textFieldMailContact);
		
		lblMailDeContact = new JLabel("Mail de contact");
		lblMailDeContact.setBounds(12, 118, 102, 16);
		contentPane.add(lblMailDeContact);
	}
	
	public void setEtat (int etat){
		switch (etat) {
		case initiale: {
			btnEnregistrer.setEnabled(true);
			btnAnnuler.setEnabled(true);
			break;
			}
		}
	}
}
